clc;clear;
wrdLn = 15; quant_num = 10000;
theta = quant_num*180/pi*double(fi(1/6*pi, 1, wrdLn));
u = double(fi(1023+0i, 1, wrdLn));

fprintf('输入角度:%d\n',int32(theta));

x = real(u); y = imag(u);
for iter=0:wrdLn-1
    angle = quant_num*180/pi*atan(2^(-iter));
    if (theta > 0)
        new_x = x - y*(2^(-iter));
        new_y = y + x*(2^(-iter));
        theta = theta - angle;
    else
        new_x = x + y*(2^(-iter));
        new_y = y - x*(2^(-iter));
        theta = theta + angle;
    end
    x = new_x;
    y = new_y;
end
v = x + y*1i;

fprintf('输入x:%d\n',1023);

fprintf('1023*sin(30°)*0.6072=%d\n',int32(1023*0.5/0.6072));
fprintf('sin:%d cos:%d\n',int16(new_y),int16(new_x));


